package com.aiyige.page.publish.majorcourse.util;

import android.text.TextUtils;

import com.aiyige.page.interest.model.Interest;
import com.aiyige.page.publish.majorcourse.model.ClassLocation;
import com.aiyige.utils.ListUtil;

import java.util.LinkedList;
import java.util.List;

public class ClassLocationUtil {
    public static boolean checkEqual(List<ClassLocation> sourceList, List<ClassLocation> destList) {
        if (ListUtil.isEmpty(sourceList) && ListUtil.isEmpty(destList)) return true;
        if (ListUtil.isEmpty(sourceList) || ListUtil.isEmpty(destList)) return false;
        if (sourceList.size() != destList.size()) return false;
        outLoop:
        for (ClassLocation src : sourceList) {
            for (ClassLocation dest : destList) {
                if (src.getId() == null && dest.getId() == null) continue outLoop;
                if (src.getId() == null || dest.getId() == null) continue;
                if (src.getId().equals(dest.getId())) continue outLoop;
            }
            return false;
        }
        return true;
    }

    public static List<String> extractIdList(List<ClassLocation> classLocationList) {
        List<String> idList = new LinkedList<>();
        for (ClassLocation classLocation : classLocationList) {
            if (TextUtils.isEmpty(classLocation.getId())) continue;
            idList.add(classLocation.getId());
        }
        return idList;
    }

}
